/* 
所有的路由配置
*/


// import MSite from '../pages/MSite/MSite'
// import Order from '../pages/Order/Order.vue'
// import Profile from '../pages/Profile/Profile.vue'
// import Search from '../pages/Search/Search.vue'


// 用动态import 实现路由懒加载
/* 
路由组件懒加载:
    1). 在打包时路由组件会被单独打包(代码分割: code split)
    2). 默认不请求加载路由组件打包文件, 当请求需要路由组件时才请求加载
1. import动态引入: 
    import(模块路径)
    结果: 被引入的模块会被单独打包(代码分割: code split)
2. 配置的路由组件是函数(返回动态加载的路由组件模块)
    函数开始是不执行(开始不请求加载单独打包的路由组件模块代码)
    当请求对应路径需要显示组件界面时, 去加载路由组件打包文件

作用: 减小首屏需要加载的js文件 ==> 显示更快
*/
const MSite = () => import('../pages/MSite/MSite')
const Order = () => import('../pages/Order/Order.vue')
const Profile = () => import('../pages/Profile/Profile.vue')
const Search = () => import('../pages/Search/Search.vue')

import shimi from '../pages/test/shimi'
import shimi2 from '../pages/test/shimi2'

import Login from '../pages/Login/Login.vue'
import Userinfo from '../pages/Userinfo/Userinfo.vue'
import Shop from '../pages/Shop/Shop.vue'
import ShopGoods from '../pages/Shop/ShopGoods/ShopGoods.vue'
import ShopRatings from '../pages/Shop/ShopRatings/ShopRatings.vue'
import Shopinfo from '../pages/Shop/Shopinfo/Shopinfo.vue'

export default [{
    path: '/msite',
    component: MSite,
    name: 'msite',
    meta: {
      isShowFooterGuide: true //用于路由为这四个时，显示底部导航，其他不显示。
    }
  },
  {
    path: '/order',
    component: Order,
    name: 'order',
    meta: {
      isShowFooterGuide: true
    }
  },
  {
    path: '/profile',
    component: Profile,
    name: 'profile',
    meta: {
      isShowFooterGuide: true
    }
  },
  {
    path: '/search',
    component: Search,
    name: 'search',
    meta: {
      isShowFooterGuide: true
    }
  },
  {
    path: '/login',
    component: Login,
    name: 'login'
  },
  {
    path: '/userinfo',
    component: Userinfo,
    name: 'userinfo'
  }, {
    path: '/shop/:id',
    component: Shop,
    name: 'shop',
    props: true, // 将所有params参数转换成标签属性传递给子路由组件
    // props: toRoute => ({id: toRoute.params.id})
    children: [{
        path: 'goods',
        component: ShopGoods,
        name: 'shopGoods'
      },
      {
        path: 'ratings',
        component: ShopRatings,
        name: 'shopRatings'
      }, {
        path: 'info',
        component: Shopinfo,
        name: 'shopinfo'
      },
      {
        path: '',
        redirect: 'goods'
      }
    ]
  }, {
    path: '/shimi',
    component: shimi,
    name: 'shimi'

  },
  {
    path: '/shimi2',
    component: shimi2,
    name: 'shimi2'

  },

  {
    path: '/',
    redirect: '/msite'
  }
]